package com.artfii.fluentsql.core.jdbc;

import com.artfii.fluentsql.core.tools.Attr;
import com.artfii.fluentsql.core.mock.Dept;
import com.artfii.fluentsql.core.mock.User;

public class Lq<T> extends Qe<T> {

    public Lq(){
        this.test_mode = true; //没有传入实体类，就当然是测试模式
        this.show_debug_sql = true;
    }

    public Lq(Class<T> clz) {
        super(clz);
    }
    public Lq<T> test(){
        this.test_mode = true;
        this.debug();
        return this;
    }

    public static void main(String[] args) throws Exception {
        String sql =new Lq<User>(User.class).test()
                .select(User::getUserName)
                .select(Attr.parse(Dept::getDeptName))
                .leftJoin(Dept.class)
                .andLike(User::getUserName, "jack")
                .asc(User::getDeptId)
                .desc(User::getUserName)
                .group(User::getDeptId)
                .having(User::getDeptId, Opt.GT, 0)
                .build();

        System.out.println("sql=" + sql);
    }


}
